using TMPro;
using UnityEngine;

public class BattleBubble : MonoBehaviour
{
	public TextMeshPro text;

	public SpriteRenderer bubble;

	public Transform arrow;

	[Header("Arrow")]
	[SerializeField]
	private float ArrowDistanceFromPivot = 1f;

	[Header("Text")]
	[SerializeField]
	private float DistanceFromArrow = 0.3f;

	[Header("Bubble")]
	[SerializeField]
	private float BubblePadding = 0.25f;

	private void LateUpdate()
	{
		if ((bool)text && (bool)bubble && (bool)arrow)
		{
			arrow.transform.position = base.transform.position + Vector3.left * ArrowDistanceFromPivot;
			float y = text.preferredHeight / 2f;
			text.transform.position = base.transform.position + Vector3.left * (ArrowDistanceFromPivot + DistanceFromArrow) + new Vector3(0f, y, 0f);
			float num = (0.5f - text.rectTransform.pivot.x) * text.rectTransform.rect.width;
			bubble.transform.position = new Vector3(text.transform.position.x + num, arrow.transform.position.y, 0f);
			bubble.size = new Vector2(text.rectTransform.sizeDelta.x + BubblePadding, text.preferredHeight + BubblePadding);
		}
	}
}
